package com.wjy.common.authentication.user.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.wjy.common.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * <p>
 *
 * </p>
 *
 * @author ybxxszl
 * @since 2019-04-12
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value = "UserToken对象", description = "")
public class UserToken extends BaseEntity {

    @ApiModelProperty(value = "用户令牌ID")
    @TableId(value = "user_token_id", type = IdType.UUID)
    private String userTokenId;

    @ApiModelProperty(value = "用户名")
    @TableField("username")
    private String username;

    @ApiModelProperty(value = "令牌")
    @TableField("token")
    private String token;

    @ApiModelProperty(value = "最后使用时间")
    @TableField("last_use_time")
    private Date lastUseTime;

    @ApiModelProperty(value = "逻辑删除")
    @TableField(value = "logic_delete", fill = FieldFill.INSERT)
    @TableLogic
    private Integer logicDelete;

    @ApiModelProperty(value = "乐观锁")
    @TableField(value = "version", fill = FieldFill.INSERT)
    @Version
    private Integer version;

    @ApiModelProperty(value = "添加人ID")
    @TableField(value = "insert_id", fill = FieldFill.INSERT)
    private String insertId;

    @ApiModelProperty(value = "添加时间")
    @TableField(value = "insert_time", fill = FieldFill.INSERT)
    private Date insertTime;

    @ApiModelProperty(value = "更新人ID")
    @TableField(value = "update_id", fill = FieldFill.UPDATE)
    private String updateId;

    @ApiModelProperty(value = "更新时间")
    @TableField(value = "update_time", fill = FieldFill.UPDATE)
    private Date updateTime;


    public static final String USER_TOKEN_ID = "user_token_id";

    public static final String USERNAME = "username";

    public static final String TOKEN = "token";

    public static final String LAST_USE_TIME = "last_use_time";

    public static final String LOGIC_DELETE = "logic_delete";

    public static final String VERSION = "version";

    public static final String INSERT_ID = "insert_id";

    public static final String INSERT_TIME = "insert_time";

    public static final String UPDATE_ID = "update_id";

    public static final String UPDATE_TIME = "update_time";

    public UserToken(String userTokenId, String token, Date lastUseTime) {
        this.userTokenId = userTokenId;
        this.token = token;
        this.lastUseTime = lastUseTime;
    }

    public UserToken(String userTokenId, String username, String token, Date lastUseTime) {
        this.userTokenId = userTokenId;
        this.username = username;
        this.token = token;
        this.lastUseTime = lastUseTime;
    }

}
